package main

import (
	"bufio"
	"os"
)

// 把文件读出来
func ReadIsbnFromFile(fileName string) ([]*BookItem, error) {
	file, err := os.Open(fileName)
	if err != nil {
		return nil, err
	}
	reader := bufio.NewReader(file)
	var books []*BookItem
	var index = 0
	for {
		line, _, err := reader.ReadLine()
		if err != nil {
			break
		}
		// 略过空白行
		//if len(line) != 0 && len(strings.TrimSpace(string(line))) != 0 {
		books = append(books, &BookItem{Index: index, Isbn: string(line)})
		index++
		//}
	}
	return books, nil
}
